#!/bin/bash
source /home/vlog_platform/venv/bin/activate
SERVICE_PATH="/home/vlog_platform/main/"
export PYTHONPATH="/home/vlog_platform"
export LD_LIBRARY_PATH=/usr/local/python3913/lib:/usr/local/postgresql133/lib:$LD_LIBRARY_PATH
WEBSERVICE_NAME=webService.py
PAY_NAME=payService.py
APPSERVICE_NAME=appService.py
DATASERVICE_NAME=dataService.py
RECORDSERVICE_NAME=recordService.py

webService_pid="`ps -ef |grep "$WEBSERVICE_NAME" |grep -v "grep" |awk '{print $2}'`"
pay_pid="`ps -ef |grep "$PAY_NAME" |grep -v "grep" |awk '{print $2}'`"
app_pid="`ps -ef |grep "$APPSERVICE_NAME" |grep -v "grep" |awk '{print $2}'`"
data_pid="`ps -ef |grep "$DATASERVICE_NAME" |grep -v "grep" |awk '{print $2}'`"
pid_down="`ps -ef |grep "$down" |grep -v "grep" |awk '{print $2}'`"
record_pid="`ps -ef |grep "$RECORDSERVICE_NAME" |grep -v "grep" |awk '{print $2}'`"

  
if [ -z "$webService_pid" ];then
        nohup python3 $SERVICE_PATH/webService.py >> $SERVICE_PATH/webService.log 2>&1 &
        echo "webService.py已开启"
else
        echo "webService.py服务正在运行中"
fi
if [ -z "$pay_pid" ];then
        nohup python3 $SERVICE_PATH/payService.py >> $SERVICE_PATH/payService.log 2>&1 &
        echo "payService.py已开启"
else
        echo "payService.py服务正在运行中"
fi
if [ -z "$app_pid" ];then
        nohup python3 $SERVICE_PATH/appService.py >> $SERVICE_PATH/appService.log  2>&1 &
        echo "appService.py已开启"
else
        echo "appService.py服务正在运行中"
fi
if [ -z "$data_pid" ];then
        nohup python3 $SERVICE_PATH/dataService.py >> $SERVICE_PATH/dataService.log  2>&1 &
        echo "dataService.py已开启"
else
        echo "dataService.py服务正在运行中"
fi
if [ -z "$record_pid" ];then
        nohup python3 $SERVICE_PATH/recordService.py >> $SERVICE_PATH/recordService.log  2>&1 &
        echo "recordService.py已开启"
else
        echo "recordService.py服务正在运行中"
fi
